package com.sdp.th.netty.actor;

import com.sdp.core.bizc.utils.ApplicationContextUtils;
import com.sdp.th.netty.bizc.BusinessFactory;
import com.sdp.th.netty.pojo.NettyMessage;
import com.sdp.th.netty.utils.NettyUtils;

import akka.actor.UntypedActor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class BusinessActor extends UntypedActor{

	@Override
	public void onReceive(Object message) throws Exception {
		try {
			NettyMessage nettyMessage = (NettyMessage) message;
			ApplicationContextUtils.getBean(BusinessFactory.class).businessMap.get(nettyMessage.getBusinessType()).execute(nettyMessage.getMessageContent());
			
		} catch (Exception e) {
			log.error("BusinessActor执行出现异常：{}",NettyUtils.stackTraceToString(e.getClass().getName(), e.getMessage(), e.getStackTrace()));
		}
		
	}

}
